<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<?php
session_start();
if (empty($_SESSION["loginusername"])) {
    Header("Location: firstphp.php");
}
if (!empty($_SESSION["userType"])) {
    $userType = $_SESSION["userType"];
}
if ($userType == "Therapy Assistant") {
    header("Location: javascript://history.go(-1)");
}
?>
<html>
    <head>
        <title>Verify Attendance</title>
        <link rel="stylesheet" type="text/css" href="http://localhost/Eldercare/jquery/easyui.css">
        <link rel="stylesheet" type="text/css" href="http://localhost/Eldercare/jquery/icon.css">
        <script type="text/javascript" src="http://localhost/Eldercare/jquery/jquery-1.4.4.min.js"></script>
        <script type="text/javascript" src="http://localhost/Eldercare/jquery/jquery-1.6.1.min.js"></script>

        <script type="text/javascript" src="http://localhost/Eldercare/jquery/jquery.easyui.min.js"></script>
        <style type="text/css">
            #fm{
                margin:0;
                padding:10px 30px;
            }
            .ftitle{
                font-size:14px;
                font-weight:bold;
                color:#666;
                padding:5px 0;
                margin-bottom:10px;
                border-bottom:1px solid #ccc;
            }
            .fitem{
                margin-bottom:5px;
            }
            .fitem label{
                display:inline-block;
                width:80px;
            }
            .btn
            {
                background-color:#FFF5EE;
                cursor:pointer;
            }
            .button 
            {
                background-color:beige;
                cursor:pointer; }

        </style>
        <link href="http://localhost/Eldercare/finalstyle.css" rel="stylesheet" type="text/css" media="all" />
        <script type="text/javascript">
            var url;
            function removeAttendance() {
                var rows = $('#dg').datagrid('getSelections');
                if (rows) {
                    $.messager.confirm('Confirm Delete Attendance', 'Are you sure you want to remove this attendance?', function(r) {
                        if (r) {
                            for (var i = 0; i < rows.length; i++)
                            {
                                var row = rows[i];
                                $.post('CRUDVerify/remove_verify.php?', {AttendanceRecordID: row.AttendanceRecordID}, function(result) {
                                    if (result.success) {
                                        $('#dg').datagrid('reload');	// reload the user data
                                    } else {
                                        $.messager.show({// show error message
                                            title: 'Error',
                                            msg: result.msg
                                        });
                                    }
                                }, 'json');
                            }
                        }
                    });
                }
            }
            function verifyAttendance() {
                var rows = $('#dg').datagrid('getSelections');
                if (rows) {
                    $.messager.confirm('Confirm Verify Attendance', 'Are you sure you want to verify this attendance?', function(r) {
                        if (r) {
                            for (var i = 0; i < rows.length; i++)
                            {
                                var row = rows[i];


                                $.post('CRUDVerify/verify.php?', {AttendanceRecordID: row.AttendanceRecordID}, function(result) {
                                    if (result.success) {
                                        $('#dg').datagrid('reload');	// reload the user data
                                    } else {
                                        $.messager.show({// show error message
                                            title: 'Verify',
                                            msg: result.msg
                                        });
                                    }
                                }, 'json');
                            }
                        }
                    });
                }
            }
            function getAttendance() {
                $('#dg').datagrid('load', {
                    searchid: $('#searchid').val()
                });
            }
            function findAll() {
                $('#dg').datagrid('load', {
                });
            }


            function disp_confirm($Username)
            {
                var r = confirm("Do you want to verify all?")
                if (r == true)
                {
                    $.get('CRUDVerify/update_verify.php?Username=' + $Username);
                    $('#dg').datagrid('reload');
                }
                else
                {
                }
            }

        </script>
    </head>
    <body>
        <ul>
            <div class="banner"></div>
            <div id="main">
                <div class="left-wrapper">
                    <div class="logo">
                    </div>
                    <div class="menu-wrapper">
                        <div id='cssmenu' > 
                            <ul>
                                <?php
                                if ($userType == "Therapy Assistant") {
                                    //if TA
                                    echo "<li class='has-sub' class='active'><a href='http://localhost/Eldercare/AttendanceHome.php'><span>Attendance</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/AttendanceHome.php'><span>Attendance Taking</span></a></li>
			 <li class='last'><a href='http://localhost/Eldercare/ViewAttendanceRecord.php'><span>View Attendance</span></a></li>
			 </ul>
			  </li>
			  <li class='has-sub'><a href='#'><span>Profile</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/Client.php'><span>Existing Client</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/WClient.php'><span>Withdrawn Client</span></a></li>
      </ul>
   </li>
   <li class='has-sub'><a href='http://localhost/Eldercare/ActRecords.php'><span>Activities</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/ActRecords.php'><span>Activity Recording</span></a></li>
		 <li class='last'><a href='http://localhost/Eldercare/ViewActRecord.php'><span>View Activity Records</span></a></li>
      </ul>
   </li>
   <li class='has-sub'><a href='#'><span>Reports</span></a>
   <ul>
   <li><a href='http://localhost/Eldercare/Reports.php'><span>Attendance Reports</span></a></li>
   <li class='last'><a href='http://localhost/Eldercare/ActReports.php'><span>Activity Reports</span></a></li>
   </ul>
   </li>
   <li class='last'><a href='http://localhost/Eldercare/ManagePassword.php'><span>Change Passwords</span></a></li>
     
			 ";
                                } else if ($userType == "Centre Manager") {
                                    echo "
			<li class='has-sub' class='active'><a href='http://localhost/Eldercare/AttendanceHome.php'><span>Attendance</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/AttendanceHome.php'><span>Attendance Taking</span></a></li>
			 <li><a href='http://localhost/Eldercare/ViewAttendanceRecord.php'><span>View Attendance</span></a></li>
			<li><a href='http://localhost/Eldercare/BackDate.php'><span>BackDate</span></a></li>
			<li class='last'><a href='http://localhost/Eldercare/VerifyAttendance.php'><span>Verify Attendance</span></a></li>
			</ul>
			<li class='has-sub'><a href='#'><span>Profile</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/Client.php'><span>Existing Client</span></a></li>
         <li><a href='http://localhost/Eldercare/WClient.php'><span>Withdrawn Client</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/User.php'><span>User</span></a></li>
      </ul>
   </li>
   <li class='has-sub'><a href='http://localhost/Eldercare/ActRecords.php'><span>Activities</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/ActRecords.php'><span>Activity Recording</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/ViewActRecord.php'><span>View Activity Records</span></a></li>
      </ul>
   </li>
   <li class='has-sub'><a href='#'><span>Reports</span></a>
   <ul>
   <li><a href='http://localhost/Eldercare/Reports.php'><span>Attendance Reports</span></a></li>
   <li class='last'><a href='http://localhost/Eldercare/ActReports.php'><span>Activity Reports</span></a></li>
   </ul>
   </li>
    <li class='has-sub'><a href='#'><span>Password</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/ManagePassword.php'><span>Change Passwords</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/ForgetPasswords.php'><span>Forget Password</span></a></li>
      </ul>
   </li>
			";
                                } else {
                                    echo "
			<li class='has-sub' class='active'><a href='http://localhost/Eldercare/AttendanceHome.php'><span>Attendance</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/AttendanceHome.php'><span>Attendance Taking</span></a></li>
			 <li><a href='http://localhost/Eldercare/ViewAttendanceRecord.php'><span>View Attendance</span></a></li>
			<li><a href='http://localhost/Eldercare/BackDate.php'><span>BackDate</span></a></li>
			<li class='last'><a href='http://localhost/Eldercare/VerifyAttendance.php'><span>Verify Attendance</span></a></li>
			</ul>
			<li class='has-sub'><a href='#'><span>Profile</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/Client.php'><span>Existing Client</span></a></li>
         <li><a href='http://localhost/Eldercare/WClient.php'><span>Withdrawn Client</span></a></li>
         <li><a href='http://localhost/Eldercare/User.php'><span>User</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/Centres.php'><span>Centres</span></a></li>
      </ul>
   </li>
   <li class='has-sub'><a href='http://localhost/Eldercare/ActRecords.php'><span>Activities</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/Activities.php'><span>Manage Current Activities</span></a></li>
         <li><a href='http://localhost/Eldercare/ActRecords.php'><span>Activity Recording</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/ViewActRecord.php'><span>View Activity Records</span></a></li>
      </ul>
   </li>
   <li><a href='http://localhost/Eldercare/Holidays.php'><span>Holiday</span></a></li>
<li class='has-sub'><a href='#'><span>Reports</span></a>
   <ul>
   <li><a href='http://localhost/Eldercare/Reports.php'><span>Attendance Reports</span></a></li>
   <li class='last'><a href='http://localhost/Eldercare/ActReports.php'><span>Activity Reports</span></a></li>
   </ul>
   </li>
    <li class='has-sub'><a href='#'><span>Password</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/ManagePassword.php'><span>Change Passwords</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/ForgetPasswords.php'><span>Forget Password</span></a></li>
      </ul>
   </li>
			";
                                }
                                ?>
                            </ul>
                        </div>
                        <div class="clear"></div></div></div>
                <div class="content">
                    <div class="content2">
                        <b style="float:right; margin: 0px 0 0 0">  <?php
                                //session_start();
                                if (!empty($_SESSION["centreName"])) {
                                    $Username = $_SESSION["loginusername"];
                                    $centreName = $_SESSION["centreName"];
                                    echo "Welcome, " . $Username . " ! <br>" . $centreName . " Branch";
                                } else {
                                    $Username = $_SESSION["loginusername"];
                                    echo "Welcome, " . $Username;
                                }
                                ?>

                            <?php
                            ?>
                            <input type="submit" class="button" value="Logout" onclick="parent.location = 'logout.php';"></b>
                        </p><div class="clear"></div>



                        <div style="float:center">
                            <h3>Verify Attendance</h3>
                            <br>
                            <?php
                            if($userType!="System Admin")
                            {
                                echo "<input type ='button' button class='btn'onclick='disp_confirm();' value ='Verify All' >";
                            }
                            ?>
                            
                            <table id="dg" title="Verify Attendance" class="easyui-datagrid" style="width:auto;height:390px; "
                                   url="CRUDVerify/get_verify.php"
                                   toolbar="#toolbar" pagination="true"
                                   rownumbers="true" fitColumns="true" singleSelect="false">
                                <thead>
                                    <tr>
                                        <th
                                    <th field="NRIC" width="50">NRIC</th>
                                    <th field="CustomerName" width="50">Name</th>
                                    <?php
                                    if ($userType == "System Admin") {
                                        echo "<th field='CentreName' width='50'>Centre Name</th>";
                                    }
                                    ?>
                                    <th field="Date" width="50">Date</th>
                                    <th field="TimeIn" width="50" >Time In</th>
                                    <th field="TimeOut" width="50"> Time Out</th>
                                    <th field="Status" width="50">Status</th>
                            <tbody style="display:none">
                            <th field="AttendanceRecordID" width="auto">Attendance Record ID</th></tbody>
                            </tr>
                            </thead>
                        </table>
                        <div id="toolbar">
                            <a href='#' class='easyui-linkbutton' iconCls='icon-remove' plain='true' onclick='removeAttendance()'>Remove Attendance</a>
                            <?php
                             if($userType!="System Admin")
                            {
                                echo "
                            <a href='#' class='easyui-linkbutton' iconCls='icon-ok' plain='true' onclick='verifyAttendance()'>Verify Attendance</a>";
                            }
                            ?>
                            
                            <input id="searchid" name="searchid" type="text" style="border-radius:25px">  
                            <a href="#" class="easyui-linkbutton" iconCls="icon-search" onClick="getAttendance()">Search</a>
                            <a href="#" class="easyui-linkbutton" onClick="findAll()">All</a>
                        </div>


                        <!-- Update Dialog and Form 
                        <div>
                        <div id="updatedlg" class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px"
                                        closed="true" buttons="#updatedlg-buttons">
                                <div class="ftitle">Attendance Information</div>
                                <form id="updateform" method="post" novalidate>
                                        <div class="fitem">
                                                <label>NRIC: </label>
                                                <input name="NRIC" type="text" disabled>
                                        </div>
                                        <div class="fitem">
                                                <label>Name: </label>
                                                <input name="CustomerName" type="text" disabled>
                                        </div>
                                        <div class="fitem">
                                        <label>Date: </label>
                                                <input name="Date" type="date"/>
                                        </div>
                                        <div class="fitem">
                                                <label>Time In:</label>
                                                <input name="TimeIn" type="time" class="easyui-validatebox" required="true">
                                        </div>
                                        <div class="fitem">
                                                <label>Time Out: </label>
                                                <input name="TimeOut" type="time"class="easyui-validatebox" >
                                        </div>
                                        <div class="fitem">
                                        <input name="AttendanceRecordID" type="hidden">
                                        </div>
                                </form>
                        </div>
                        <div id="updatedlg-buttons">
                                <a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="updateAttendance()">Save</a>
                                <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#updatedlg').dialog('close')">Cancel</a>
                        </div>
                        </div>
                        </div><p>-->
                    </div>
                        <p></p>
                    <div class="clear"></div></div>
            </div>
            </body></div>
</html>